<template>
  <div>
    <el-container>
      <!--Header-->
      <el-header>
        <navigation :suserInfo="userInfo"></navigation>
      </el-header>
      <!--Main-->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>

  // 导航
  import Navigation from '../../components/Navigation/Navigation'

  // jwt 解析token
  import jwtDecode from 'jwt-decode'

  export default {
    name: "Home",
    data() {
      return {
        userInfo: {},
      }
    },
    components: {
      Navigation
    },
    created() {
      const token = jwtDecode(window.sessionStorage.getItem("token"))

      if (token.userid !== null) {
        this.$http.get(`user/${token.userid}`).then(result => {
          if (result.data.meta.status != 200) return this.$message.error(result.data.meta.message)
          this.userInfo = result.data.data
          console.log(this.userInfo);
        })
      }
    }
  }
</script>

<style scoped>
  .el-header {
    padding: 0px;
  }
</style>